package office.action.sale;



import java.util.List;

import javax.annotation.Resource;

import office.bo.sale.impl.CustomerProp;
import office.service.sale.ICustomerPropService;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import platform.common.action.BaseAction;

@Namespace("/cprop")
@ParentPackage("struts-base")
@Controller("customerPropAction")
@Scope("prototype")
public class CustomerPropAction extends BaseAction {
	
	@Resource
	private ICustomerPropService customerPropService;
	
	private List<CustomerProp> cpList;
	
	private CustomerProp customerProp;
	
	private String customerPropId;

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Action(value="gotoCustomerPropMenu",results={@Result(location="/pages/sale/customerPropXml.jsp")})
	public String gotoCustomerPropMenu(){
		return "success";
	}

	@Action(value="gotoEditCustomerProp",results={@Result(location="/pages/sale/customerPropEdit.jsp")})
	public String gotoEditCustomerProp(){
		if(customerPropId != null){
			customerProp = customerPropService.getCustomerPropById(customerPropId);
		}
		return "success";
	}
	
	@Action(value="gotoDeleteCustomerProp",results={@Result(location="/pages/sale/customerPropDel.jsp")})
	public String gotoDeleteCustomerProp(){
		return "success";
	}
	
	@Action(value="delCustomerProp")
	public String delCustomerProp(){
		customerPropService.deleteCustomerProp(customerPropId);
		this.getAjaxMessagesJson().setMessage(true, "", "删除成功");
		return RESULT_AJAXJSON;
	}
	
	@Action(value="editCustomerProp")
	public String editCustomerProp(){
		if(customerPropId != null && customerPropId != null && customerPropId.equals("")){
			customerProp.setId(null);
		}else{
			customerProp.setId(customerPropId);
		}
		customerPropService.saveCustomerProp(customerProp);
		this.getAjaxMessagesJson().setMessage(true, "", "编辑成功");
		return RESULT_AJAXJSON;
	}
	
	@Action(value="getAllCustomerProp",results={@Result(location="/pages/sale/customerProp.jsp")})
	public String getAllCustomerProp(){
		cpList = customerPropService.getAllCustomerProp();
		return "success";
	}

	public ICustomerPropService getCustomerPropService() {
		return customerPropService;
	}

	public void setCustomerPropService(ICustomerPropService customerPropService) {
		this.customerPropService = customerPropService;
	}

	public List<CustomerProp> getCpList() {
		return cpList;
	}

	public void setCpList(List<CustomerProp> cpList) {
		this.cpList = cpList;
	}

	public CustomerProp getCustomerProp() {
		return customerProp;
	}

	public void setCustomerProp(CustomerProp customerProp) {
		this.customerProp = customerProp;
	}

	public String getCustomerPropId() {
		return customerPropId;
	}

	public void setCustomerPropId(String customerPropId) {
		this.customerPropId = customerPropId;
	}
	
}
